﻿using Assessment.BLL;
using Assessment.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Index_Gauge_GaugeRecordView : BasePage_Index
{
    #region 属性
    /// <summary>
    /// Id
    /// </summary>
    public int Id
    {
        get
        {
            return ViewState["Id"] == null ? 0 : Convert.ToInt32(ViewState["Id"]);
        }
        set
        {
            ViewState["Id"] = value;
        }
    }

    public int MedicalRecordId
    {
        get { return Request.QueryString["MedicalRecordId"] == null ? 0 : Convert.ToInt32(Request.QueryString["MedicalRecordId"]); }
    }
    public int GaugeRecordId
    {
        get { return Request.QueryString["GaugeRecordId"] == null ? 0 : Convert.ToInt32(Request.QueryString["GaugeRecordId"]); }
    }

    /// <summary>
    /// Action
    /// </summary>
    private string Action
    {
        get
        {
            return ViewState["Action"] == null ? "Add" : ViewState["Action"].ToString();
        }
        set
        {
            ViewState["Action"] = value;
        }
    }

    /// <summary>
    /// EditType
    /// </summary>
    private string EditType
    {
        get
        {
            return ViewState["EditType"] == null ? "" : ViewState["EditType"].ToString();
        }
        set
        {
            ViewState["EditType"] = value;
        }
    }
    #endregion

    T_MedicalRecordBLL medical_bll = new T_MedicalRecordBLL();
    T_AssessmentBLL assessment_bll = new T_AssessmentBLL();

    UtilityBLL ubll = new UtilityBLL();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            base.SetBtnGotoBackUrl("/Index/MedicalRecord/MedicalRecordList.aspx");

            getBaseDate();

            BindGaugeRecordRepeater();

            //绑定评估项目Repeater
            BindGaugeProject();
        }
    }

    #region 绑定基本信息
    /// <summary>
    /// 加载数据
    /// </summary>
    /// <param name="id"></param>
    private void getBaseDate()
    {
        T_MedicalRecord MedicalRecord = medical_bll.GetModel(MedicalRecordId);
        if (MedicalRecord == null)
        {
            base.Alert("获取数据失败！");
            return;
        }
        this.lbl_Name.Text = MedicalRecord.Name;
        this.lbl_Gender.Text = MedicalRecord.Gender == 1 ? "男" : "女";
        this.lbl_BirthDay.Text = MedicalRecord.Birthday;

        T_Assessment Assessment = assessment_bll.GetModelList("1=1").FirstOrDefault();
        if (Assessment == null)
        {
            return;
        }
        //基本评估
        this.lbl_Abstract1.Text = Assessment.Abstract1;
        this.lbl_Abstract2.Text = Assessment.Abstract1;
        this.lbl_Abstract3.Text = Assessment.Abstract1;
        this.lbl_Abstract4.Text = Assessment.Abstract1;
        this.lbl_Abstract5.Text = Assessment.Abstract1;
        this.lbl_Abstract6.Text = Assessment.Abstract1;
        this.lbl_Abstract7.Text = Assessment.Abstract1;
        this.lbl_Abstract8.Text = Assessment.Abstract1;
        this.lbl_Abstract9.Text = Assessment.Abstract1;
        this.lbl_Abstract10.Text = Assessment.Abstract1;
        this.lbl_Abstract11.Text = Assessment.Abstract1;
        this.lbl_Abstract12.Text = Assessment.Abstract1;
        this.lbl_Report.Text = Assessment.Report;
        this.lbl_PhysicalExamination.Text = Assessment.PhysicalExamination;
        this.lbl_ImagingExamination.Text = Assessment.ImagingExamination;
        this.lbl_SpecialCircumstances.Text = Assessment.SpecialCircumstances;
    }

    #endregion

    #region 绑定评估记录
    private void BindGaugeRecordRepeater()
    {
        int rCount = 0;
        DataTable dt = ubll.GetListByPage("T_GaugeRecord", "*", "CreateDate", "Valid=1 and MedicalRecordId=" + MedicalRecordId, 10000, 1, 0, out rCount);
        this.rpt_GaugeRecord.DataSource = dt;
        this.rpt_GaugeRecord.DataBind();
    }
    #endregion

    #region 绑定评估项目
    private void BindGaugeProject()
    {
        int rCount = 0;
        DataTable dt = ubll.GetListByPage("View_GaugeRecord", "*", "CreateDate", "GaugeRecordId=" + GaugeRecordId, 10000, 1, 0, out rCount);
        this.rpt_Gauge.DataSource = dt;
        this.rpt_Gauge.DataBind();
    }
    #endregion
}